using Microsoft.AspNetCore.Mvc;
using JTZY.Model.Order.Dto;
using JTZY.Model.Order;
using JTZY.Service.Order.IOrderService;
using JTZY.Admin.WebApi.Filters;

//创建时间：2024-12-30
namespace JTZY.Admin.WebApi.Controllers.Order
{
    /// <summary>
    /// 订单记录表
    /// </summary>
    [Verify]
    [Route("order/Corecmsorderlog")]
    public class CorecmsorderlogController : BaseController
    {
        /// <summary>
        /// 订单记录表接口
        /// </summary>
        private readonly ICorecmsorderlogService _CorecmsorderlogService;

        public CorecmsorderlogController(ICorecmsorderlogService CorecmsorderlogService)
        {
            _CorecmsorderlogService = CorecmsorderlogService;
        }

        /// <summary>
        /// 查询订单记录表列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "corecmsorderlog:list")]
        public IActionResult QueryCorecmsorderlog([FromQuery] CorecmsorderlogQueryDto parm)
        {
            var response = _CorecmsorderlogService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询订单记录表详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "corecmsorderlog:query")]
        public IActionResult GetCorecmsorderlog(int Id)
        {
            var response = _CorecmsorderlogService.GetInfo(Id);
            
            var info = response.Adapt<CorecmsorderlogDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加订单记录表
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "corecmsorderlog:add")]
        [Log(Title = "订单记录表", BusinessType = BusinessType.INSERT)]
        public IActionResult AddCorecmsorderlog([FromBody] CorecmsorderlogDto parm)
        {
            var modal = parm.Adapt<Corecmsorderlog>().ToCreate(HttpContext);

            var response = _CorecmsorderlogService.AddCorecmsorderlog(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新订单记录表
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "corecmsorderlog:edit")]
        [Log(Title = "订单记录表", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateCorecmsorderlog([FromBody] CorecmsorderlogDto parm)
        {
            var modal = parm.Adapt<Corecmsorderlog>().ToUpdate(HttpContext);
            var response = _CorecmsorderlogService.UpdateCorecmsorderlog(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除订单记录表
        /// </summary>
        /// <returns></returns>
        [HttpPost("delete/{ids}")]
        [ActionPermissionFilter(Permission = "corecmsorderlog:delete")]
        [Log(Title = "订单记录表", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteCorecmsorderlog([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_CorecmsorderlogService.Delete(idArr));
        }

    }
}